package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.CommissionService;
import com.yixun.qfbao.apidto.GetCustomerPremisesReqDto;
import com.yixun.qfbao.apidto.GetCustomerPremisesResDto;
import com.yixun.qfbao.apidto.GetCustomerPremisesWeAppResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetCustomerPremisesReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description 小程序
 */
@Service("getCustomerPremisesWeAppHander")
public class GetCustomerPremisesWeAppHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetCustomerPremisesWeAppHander.class);

    @Autowired
    private CommissionService commissionService;

    @SuppressWarnings("rawtypes")
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        GetCustomerPremisesReqVo req = (GetCustomerPremisesReqVo)reqDto;
        GetCustomerPremisesReqDto getCustomerPremisesReqDto = req.getParams();
        BaseResponseDTO<GetCustomerPremisesWeAppResDto> res = new BaseResponseDTO<>();
        GetCustomerPremisesWeAppResDto resDto = new GetCustomerPremisesWeAppResDto();
        try {
            resDto = commissionService.getCustomerPremisesWeApp(getCustomerPremisesReqDto);
        } catch (Exception e) {
            logger.error("GetCustomerPremisesWeAppHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("获取个人佣金失败!");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
